package com.huwei.boxuegu.activity;

import android.app.FragmentManager;
import android.app.FragmentTransaction;
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.view.View;

import com.huwei.boxuegu.R;
import com.huwei.boxuegu.fragment.CourseFragment;
import com.huwei.boxuegu.fragment.ExerciseFragment;
import com.huwei.boxuegu.fragment.MyFragment;

public class MainActivity extends AppCompatActivity {
    FragmentManager fragmentManager;
    FragmentTransaction fragmentTransaction;
    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);

        setContentView(R.layout.activity_main);
         fragmentManager = getFragmentManager();
       fragmentTransaction = fragmentManager.beginTransaction();
        fragmentTransaction.add(R.id.fragment,new CourseFragment());
        fragmentTransaction.commit();
    }

    public void exercise(View view){
        fragmentTransaction = fragmentManager.beginTransaction();
        fragmentTransaction.replace(R.id.fragment,new ExerciseFragment());
        fragmentTransaction.commit();
    }
    public void course(View view){
        fragmentTransaction = fragmentManager.beginTransaction();
        fragmentTransaction.replace(R.id.fragment,new CourseFragment());
        fragmentTransaction.commit();
    }
    public void my(View view){
        fragmentTransaction = fragmentManager.beginTransaction();
        fragmentTransaction.replace(R.id.fragment,new MyFragment());
        fragmentTransaction.commit();
    }
}
